package com.li.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.li.drug.entity.Returnsupplier;
import com.li.drug.mapper.ReturnsupplierMapper;
import com.li.drug.service.ReturnsupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;

@Service
public class ReturnsupplierServiceImpl extends ServiceImpl<ReturnsupplierMapper, Returnsupplier> implements ReturnsupplierService {

    @Autowired
    ReturnsupplierMapper returnsupplierMapper;

    /**
     * 分页查询对象
     * @param pageNum 第几页
     * @param pageSize 每页多少条数据
     * @param param 查询参数
     * @return
     */
    @Override
    public Page<Returnsupplier> selectReturnsupplierPage(int pageNum, int pageSize, String param) {
        QueryWrapper<Returnsupplier> wrapper = new QueryWrapper<>();
        if(!StringUtils.isEmpty(param)){
            wrapper.like("dname",param);
        }
        Page<Returnsupplier> page = new Page<>(pageNum,pageSize);
        return returnsupplierMapper.selectPage(page,wrapper);
    }

    @Override
    public int addReturnsupplier(Returnsupplier returnsupplier) {
        return returnsupplierMapper.insert(returnsupplier);
    }

    @Override
    public int editReturnsupplier(Returnsupplier returnsupplier) {
       return returnsupplierMapper.updateById(returnsupplier);
    }

    @Override
    public Returnsupplier getReturnsupplierById(Integer id) {
        return returnsupplierMapper.selectById(id);
    }

    @Override
    public int delReturnsupplierById(Integer id) {
        return returnsupplierMapper.deleteById(id);
    }
}
